<script lang="ts" setup>
  import {commonWordList} from "@/api/system";


  const globalData = {
    baseCdnUrl: "https://cdn1.visiotrip.com/h5AndMini/",
    statusBarHeight: 0,
    menuHeight: 0,
    tabHeight: 0,
    safeBottom:0,
    navHeight: 0,
    navTop: 0,
    windowHeight: 0,
    imageHeight: "",
    os: "",
    common: {
      sever_time: "", //日志到达服务器时间戳
      client_time: "", //客户端日志产生时的时间戳
      //设备信息,根据实际可获取到数据的情况进行调整
      utdid: "", // (String) 由SDK生成的设备标识 --deviceId
      brand: "", // (String) 手机或终端的品牌
      device_model: "", // (String) 手机或终端的机型
      resolution: "", // (String) 手机或终端的屏幕分辨率
      os: "", // (String) 操作系统，如: Android、iPhone OS
      os_version: "", // (String) 操作系统的版本
      carrier: "", // (String) 移动运营商，如：中国移动、中国联通、中国电信 --ios不一定能拿到
      network_type: "", // (String) 网络类型，例如4G,5G,WiFi等
      client_ip: "", // (String) 客户端ip
      //app信息,根据实际可获取到数据的情况进行调整
      source: "wechat", //数据来源端 如wechat、douying
      source_name:"阿坝",
      version_code: "", // (String) app版本号
      sdk_version: "", // (String) SDK版本号
      //用户信息,根据实际可获取到数据的情况进行调整
      user_id: "", // (String) 用户id
      user_nick: "", // (String) 用户昵称
      user_type: "", // (String) 用户类型：vtrip/vtripWechat/vtripDouyin
      longitude: "", // (String) 定位经度
      latitude: "", // (String) 定位纬度
    },
    menuRight: 0,
    appName: "",
  }
  onLaunch(() => {
      const {setSystemInfo, setMenuButtonInfo, setAppId, setLocationInfo} = useStore('app')
      setSystemInfo()
      setMenuButtonInfo()
      setAppId()
      setLocationInfo();
      queryCommonWordList();
      initGlobalData()
  });
  onShow(() => {

  });
  onHide(() => {

  });
  onMounted(() => {
    uni.hideTabBar();
  });
  const initGlobalData = async ()  => {
    let menuButtonObject = uni.getMenuButtonBoundingClientRect();
    await uni.getSystemInfo({
      success: (res) => {
        let statusBarHeight = res.statusBarHeight;
        let navTop = menuButtonObject.top;
        let navHeight =
          statusBarHeight +
          menuButtonObject.height +
          (menuButtonObject.top - statusBarHeight) * 2;
        //导航高度
        globalData.navHeight = navHeight;
        globalData.navTop = navTop;
        // 底部安全区高度
        globalData.safeBottom = res.safeAreaInsets.bottom as number;
        globalData.windowHeight = res.windowHeight;
        globalData.common.device_model = res.model;
        globalData.common.sdk_version = res.SDKVersion;
        globalData.common.os_version = res.version;
        globalData.common.os = res.system;
        globalData.common.brand = res.brand;
        globalData.statusBarHeight = statusBarHeight;
        globalData.menuHeight = menuButtonObject.height;
        globalData.tabHeight =
          res.screenHeight - res.statusBarHeight - res.windowHeight;
        globalData.menuRight = menuButtonObject.width + 20;
        uni.setStorageSync('globalData', globalData)
      },

      fail(err) {
        console.log(err);
      },
    });
    uni.getNetworkType({
      success: function (res) {
        const networkType = res.networkType;
        //不为none代表有网络
        if ("none" != networkType) {
          globalData.common.network_type = res.networkType;
          uni.setStorageSync('globalData', globalData)
        }
      },
    });
  }
  const queryCommonWordList = async () => {
    await commonWordList({keys:"MERCHANT_TKT_TAG"}).then(res => {
      let {result:MERCHANT_TKT_TAG} = res.result;
      if(MERCHANT_TKT_TAG && MERCHANT_TKT_TAG.length) {
        uni.setStorageSync("commonWordList",MERCHANT_TKT_TAG);
      }
    });
  };
</script>
<style lang="scss">
  @import "@/static/css/icon-font.css";
  @import "@/style/index.scss";

  /* 全局覆盖日历样式 */
  :root {
    /* 日期单元格背景色 */
    --wd-calendar-day-bg: #f5f5f5;
    /* 选中日期背景色 */
    --wd-calendar-day-active-bg: #ff0000;
    /* 日期字体颜色 */
    --wd-calendar-day-font-color: #333;
    /* 禁用日期字体颜色 */
    --wd-calendar-day-disabled-font-color: #999;
  }
	
	::v-deep .is-selected {
	  .wd-month__day-container {
	    background: #1b9c61 !important;
	  }
	}
	::v-deep .wd-calendar__confirm{
	  .wd-button {
	    background: #1b9c61 !important;
	  }
	}
</style>
